<template>
  <div id="app">
  <div class="home-page">
    <!-- 顶部栏 -->
    <div class="top-bar">
      <div class="logo">
        <img src="http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E7%99%BB%E5%BD%95%E9%A1%B5%E5%9B%BE%E7%89%871.png?e=1739245499&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:P-UHBpQP_kbCFp465Kix6qo8_zk=" alt="家庭医生logo" />
        <span>家庭医生</span>
        <img id="weizhi" @click="openLocation" src="http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E4%BD%8D%E7%BD%AE.png?e=1739260925&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:BC3RRXyMkntMBbH2vnhwF9I5Ww0=">
      </div>
    </div>
    <div v-if="showHeader" class="top-header">
      <div class="header-title">首页</div>
      <div class="header-extra">
        <img id="weizhi" src="http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E4%BD%8D%E7%BD%AE.png?e=1739260925&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:BC3RRXyMkntMBbH2vnhwF9I5Ww0=">
      </div>
    </div>
    <div class="search-box">
      <input
          type="text"
          placeholder="搜索机构/医生"
          v-model="searchQuery"
          @click="handleInput"
      />
      <i class="el-icon-search" @click="handleSearch"></i>
    </div>
    <!-- 轮播图 -->
    <div class="carousel">
      <div class="carousel-container">
        <div
            v-for="(item, index) in carouselItems"
            :key="index"
            class="carousel-item"
            :style="{ transform: 'translateX(' + (-currentCarouselIndex * 100) + '%)' }"
        >
          <img :src="item.image" alt="carousel-img" />
          <svg height="216" class="carousel-illustration" node-id="1" sillyvg="true" template-height="216" template-width="92" version="1.1" viewBox="0 0 92 216" width="92" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs node-id="21"></defs><g node-id="62"><path d="M 57.90 215.00 L 66.90 214.30 L 71.00 213.50 L 78.60 210.90 L 84.70 207.40 L 87.10 205.30 L 89.00 203.10 L 90.40 200.70 L 91.30 198.20 L 91.60 195.60 L 91.30 192.90 L 90.40 190.40 L 89.00 188.00 L 87.10 185.80 L 84.70 183.70 L 81.70 181.80 L 75.00 178.80 L 66.90 176.80 L 62.60 176.30 L 57.90 176.10 L 48.90 176.80 L 44.80 177.60 L 37.30 180.20 L 31.20 183.70 L 28.80 185.80 L 26.90 188.00 L 25.40 190.40 L 24.50 192.90 L 24.20 195.60 L 24.50 198.20 L 25.40 200.70 L 26.90 203.10 L 28.80 205.30 L 31.20 207.40 L 37.30 210.90 L 44.80 213.50 L 53.30 214.80 L 57.90 215.00 Z" fill="#d6d8e5" fill-opacity="0.4" fill-rule="nonzero" group-id="1" node-id="25" stroke="none" target-height="38.899994" target-width="67.399994" target-x="24.2" target-y="176.1"/></g><path d="M 85.80 47.40 L 89.20 65.10 L 89.30 70.30 L 88.70 71.80 L 87.50 73.60 L 83.80 77.10 L 74.80 83.60 L 72.90 75.10 L 80.50 67.70 L 78.50 53.60 L 85.80 47.40 Z" fill="#ffcea9" fill-rule="nonzero" node-id="28" stroke="none" target-height="36.199997" target-width="16.400002" target-x="72.9" target-y="47.4"/><path d="M 75.10 33.10 L 76.60 32.70 L 79.40 32.80 L 81.90 34.30 L 83.50 36.90 L 85.60 44.30 L 87.10 52.20 L 85.20 54.00 L 83.70 54.90 L 82.10 55.40 L 80.00 55.50 L 75.10 33.10 Z" fill="#ededed" fill-rule="nonzero" node-id="30" stroke="none" target-height="22.8" target-width="12" target-x="75.1" target-y="32.7"/><path d="M 59.50 195.00 L 57.20 195.40 L 55.00 195.30 L 52.70 194.90 L 50.60 193.90 L 42.80 192.00 L 38.10 191.60 L 36.80 191.80 L 35.90 192.40 L 35.30 193.20 L 35.10 194.40 L 35.70 196.70 L 36.90 198.20 L 40.20 200.40 L 47.00 202.70 L 52.90 205.30 L 57.00 206.00 L 58.40 205.70 L 59.60 205.00 L 60.30 203.90 L 60.70 202.10 L 60.60 198.20 L 59.50 195.00 Z" fill="#38226d" fill-rule="nonzero" node-id="32" stroke="none" target-height="14.399994" target-width="25.600002" target-x="35.1" target-y="191.6"/><path d="M 54.20 204.70 L 47.00 201.60 L 39.00 198.70 L 36.50 196.60 L 35.60 195.30 L 35.10 193.90 L 35.40 196.00 L 36.00 197.10 L 38.70 199.50 L 40.30 200.40 L 47.00 202.60 L 52.90 205.30 L 55.60 205.90 L 58.40 205.70 L 59.60 204.90 L 60.40 203.50 L 57.40 204.80 L 54.20 204.70 Z" fill="#9c73ff" fill-rule="nonzero" node-id="34" stroke="none" target-height="12" target-width="25.300003" target-x="35.1" target-y="193.9"/><path d="M 78.30 186.50 L 76.00 186.90 L 73.80 186.90 L 71.60 186.40 L 69.40 185.40 L 61.60 183.50 L 56.90 183.10 L 55.60 183.30 L 54.70 183.90 L 54.10 184.70 L 53.90 185.90 L 54.60 188.20 L 55.80 189.70 L 59.00 191.90 L 65.80 194.20 L 71.70 196.80 L 75.80 197.50 L 77.20 197.20 L 78.40 196.50 L 79.10 195.40 L 79.50 193.60 L 79.50 189.70 L 78.30 186.50 Z" fill="#38226d" fill-rule="nonzero" node-id="36" stroke="none" target-height="14.399994" target-width="25.599998" target-x="53.9" target-y="183.1"/><path d="M 73.00 196.20 L 65.80 193.20 L 57.80 190.30 L 55.30 188.20 L 54.40 186.80 L 54.00 185.40 L 54.30 187.60 L 54.90 188.60 L 57.60 191.10 L 59.10 191.90 L 65.80 194.20 L 71.70 196.80 L 74.40 197.50 L 77.20 197.20 L 78.40 196.50 L 79.20 195.10 L 76.20 196.40 L 73.00 196.20 Z" fill="#9c73ff" fill-rule="nonzero" node-id="38" stroke="none" target-height="12.100006" target-width="25.199997" target-x="54" target-y="185.4"/><path d="M 78.60 155.00 L 77.50 148.60 L 75.90 142.30 L 77.60 115.10 L 79.60 99.10 L 79.60 95.70 L 79.20 92.50 L 78.40 89.30 L 42.00 97.40 L 44.70 150.10 L 45.30 156.70 L 47.40 170.00 L 50.70 194.20 L 52.70 195.00 L 54.70 195.40 L 59.60 195.20 L 59.10 161.10 L 58.50 153.70 L 60.50 123.80 L 63.00 143.40 L 65.70 159.10 L 69.20 186.70 L 71.20 187.50 L 73.20 187.80 L 75.20 187.80 L 78.20 187.10 L 78.90 169.80 L 78.90 161.40 L 78.60 155.00 Z" fill="#50a2ff" fill-rule="nonzero" node-id="40" stroke="none" target-height="106.09999" target-width="37.6" target-x="42" target-y="89.3"/><path d="M 73.20 33.30 L 69.70 33.70 L 68.50 33.70 L 68.00 33.30 L 67.40 29.00 L 68.00 27.30 L 70.80 24.70 L 71.70 23.00 L 72.50 20.20 L 73.10 14.50 L 72.20 10.00 L 71.30 8.00 L 68.50 4.80 L 66.80 3.60 L 64.70 2.70 L 62.30 2.20 L 57.80 2.60 L 54.10 4.30 L 51.20 7.20 L 49.30 11.00 L 47.80 17.40 L 47.40 22.80 L 47.70 25.60 L 48.40 28.50 L 50.30 32.40 L 51.40 33.80 L 52.40 34.50 L 56.60 34.10 L 57.30 38.40 L 57.10 39.20 L 54.20 41.70 L 54.10 42.20 L 55.00 43.50 L 56.30 44.30 L 59.60 45.50 L 63.10 45.90 L 65.30 45.50 L 67.50 44.90 L 71.30 42.80 L 72.80 41.40 L 73.70 40.10 L 74.70 36.90 L 74.60 34.30 L 74.00 33.60 L 73.20 33.30 Z" fill="#ffcea9" fill-rule="nonzero" node-id="42" stroke="none" target-height="43.7" target-width="27.299995" target-x="47.4" target-y="2.2"/><path d="M 69.20 33.70 L 69.40 34.70 L 69.10 35.70 L 68.30 36.80 L 65.40 38.70 L 60.40 40.20 L 58.00 40.00 L 57.20 39.20 L 47.00 44.40 L 45.70 45.60 L 44.60 47.70 L 43.50 50.80 L 42.40 58.20 L 42.10 63.60 L 41.70 83.90 L 42.00 97.40 L 45.80 100.20 L 47.70 101.20 L 52.50 102.60 L 55.30 102.60 L 61.60 101.10 L 68.50 98.10 L 74.50 94.30 L 76.90 92.10 L 78.40 90.30 L 78.00 75.50 L 83.10 54.80 L 83.70 48.50 L 83.00 41.90 L 82.10 38.30 L 81.20 36.10 L 80.00 34.50 L 78.80 33.60 L 76.00 33.10 L 69.20 33.70 Z" fill="#f4f4f4" fill-rule="nonzero" node-id="44" stroke="none" target-height="69.5" target-width="41.999996" target-x="41.7" target-y="33.1"/><path d="M 30.40 75.80 L 32.40 76.20 L 35.10 75.80 L 36.60 74.90 L 37.60 73.50 L 38.80 70.30 L 42.20 54.70 L 44.10 48.80 L 45.00 47.20 L 46.90 45.20 L 49.20 44.10 L 50.70 43.90 L 51.90 44.20 L 53.00 45.20 L 53.60 46.60 L 54.00 48.80 L 53.70 52.10 L 52.40 59.30 L 50.60 66.40 L 47.00 77.50 L 44.30 82.20 L 43.10 83.40 L 41.50 84.40 L 39.50 85.10 L 37.10 85.40 L 31.60 84.90 L 28.00 84.10 L 22.90 82.10 L 7.00 74.50 L 4.50 72.60 L 2.30 70.10 L 0.80 67.50 L 0.80 66.30 L 1.60 65.90 L 2.10 66.10 L 4.80 69.00 L 7.20 70.80 L 2.90 65.70 L 1.70 63.00 L 2.10 61.70 L 2.90 61.30 L 3.30 61.50 L 6.20 65.30 L 9.00 68.00 L 6.40 63.80 L 5.60 61.90 L 5.60 59.50 L 6.70 59.10 L 7.50 59.80 L 9.50 63.30 L 10.80 64.80 L 13.20 66.80 L 12.00 63.80 L 11.80 62.50 L 12.40 60.50 L 13.50 60.00 L 16.50 65.00 L 18.20 68.90 L 19.80 70.90 L 21.10 72.10 L 23.40 73.50 L 30.40 75.80 Z" fill="#ffcea9" fill-rule="nonzero" node-id="46" stroke="none" target-height="41.5" target-width="53.2" target-x="0.8" target-y="43.9"/><path d="M 51.50 43.10 L 49.50 43.00 L 47.80 43.40 L 46.20 44.20 L 45.00 45.50 L 43.80 47.50 L 42.70 50.50 L 39.60 61.80 L 42.60 64.80 L 46.50 66.40 L 50.40 66.60 L 51.70 66.20 L 53.10 65.20 L 55.40 54.30 L 55.90 49.60 L 55.60 47.20 L 54.90 45.30 L 54.20 44.30 L 53.00 43.60 L 51.50 43.10 Z" fill="#ededed" fill-rule="nonzero" node-id="48" stroke="none" target-height="23.599998" target-width="16.300003" target-x="39.6" target-y="43"/><path d="M 53.00 24.00 L 60.00 22.00 L 59.80 21.50 L 52.80 23.60 L 53.00 24.00 Z" fill="#ffffff" fill-rule="nonzero" node-id="50" stroke="none" target-height="2.5" target-width="7.200001" target-x="52.8" target-y="21.5"/><path d="M 53.60 27.40 L 53.50 27.90 L 59.40 27.80 L 59.40 27.30 L 53.60 27.40 Z" fill="#ffffff" fill-rule="nonzero" node-id="52" stroke="none" target-height="0.6000004" target-width="5.9000015" target-x="53.5" target-y="27.3"/><path d="M 52.80 34.50 L 51.10 33.70 L 49.20 30.80 L 47.60 26.30 L 47.20 21.70 L 47.70 21.50 L 51.60 23.10 L 53.80 23.30 L 54.80 28.00 L 52.80 34.50 Z" fill="#ededed" fill-rule="nonzero" node-id="54" stroke="none" target-height="13" target-width="7.5999985" target-x="47.2" target-y="21.5"/><path d="M 48.90 12.30 L 47.50 8.70 L 47.40 7.10 L 47.80 5.40 L 49.10 3.40 L 50.30 2.40 L 53.70 1.00 L 56.50 0.40 L 59.80 0.20 L 62.80 0.50 L 65.30 1.30 L 67.70 2.60 L 69.70 4.10 L 71.30 5.90 L 72.50 8.00 L 73.40 10.20 L 73.80 12.50 L 73.90 14.80 L 73.20 19.20 L 72.00 22.30 L 68.90 27.40 L 67.40 29.00 L 64.00 29.40 L 61.70 29.10 L 58.70 28.00 L 58.50 22.50 L 59.30 18.80 L 59.10 17.30 L 57.90 14.90 L 55.50 13.30 L 53.90 12.70 L 48.90 12.30 Z" fill="#3a2c6d" fill-rule="nonzero" node-id="56" stroke="none" target-height="29.199999" target-width="26.5" target-x="47.4" target-y="0.2"/><path d="M 82.10 55.90 L 42.00 93.20 L 39.70 165.10 L 43.70 166.60 L 50.30 168.10 L 54.50 168.40 L 58.90 168.30 L 63.70 167.60 L 66.00 140.00 L 69.50 165.00 L 69.10 165.80 L 72.10 164.30 L 77.50 160.50 L 82.10 155.90 L 84.10 153.30 L 82.10 55.90 Z" fill="#f4f4f4" fill-rule="nonzero" node-id="58" stroke="none" target-height="112.49999" target-width="44.399998" target-x="39.7" target-y="55.9"/><path d="M 39.60 61.80 L 37.60 70.50 L 36.30 73.30 L 35.40 74.30 L 34.40 75.00 L 33.20 75.30 L 31.60 75.00 L 19.80 69.20 L 14.60 79.80 L 25.30 84.80 L 30.80 86.30 L 35.80 87.10 L 38.40 87.10 L 40.70 86.80 L 43.30 85.70 L 45.80 82.60 L 47.40 79.50 L 52.30 67.50 L 53.10 65.20 L 39.60 61.80 Z" fill="#ededed" fill-rule="nonzero" node-id="60" stroke="none" target-height="25.3" target-width="38.5" target-x="14.6" target-y="61.8"/></svg>
          <div class="carousel-item-content">
            <h3 style="color: black">{{ item.title }}</h3>
            <p style="color: #9a9a9a">{{ item.subtitle }}</p>
            <button @click="handleCarouselButtonClick(item.action)">{{ item.buttonText }}</button>
          </div>
        </div>
      </div>
      <div class="carousel-indicators">
        <span
            v-for="(_, index) in carouselItems.length"
            :key="index"
            :class="{ active: currentCarouselIndex === index }"
            @click="goToCarouselSlide(index)"
        ></span>
      </div>
    </div>
    <hr class="custom-hr" />
    <!-- 功能按钮区 -->
    <div class="function-buttons">
      <div
          v-for="(button, index) in functionButtons"
          :key="index"
          v-bind:style="{ backgroundColor: button.color }"
          class="function-button"
          @click="handleFunctionButtonClick(button.action)"
      >
        <img :src="button.icon" alt="功能图标" />
        <p style="color: #f7f9fb">{{ button.text }}</p>
      </div>
    </div>
    <!-- 功能列表区 -->
    <div class="function-list">
      <div
          v-for="(item, index) in functionList"
          :key="index"
          class="function-list-item"
          @click="handleFunctionListItemClick(item.action)"
      >
        <img :src="item.icon" class="function-list-item" alt="功能图标" />
        <p>{{ item.text }}</p>
      </div>
    </div>
    <hr class="custom-hr" />
    <!-- 附近机构 -->
    <div v-if="flag1" class="nearby-institutions">
      <div class="header">
        <h2>附近机构</h2>
        <a href="#" class="more1" @click.prevent="showMore">查看更多 ></a>
      </div>
      <div v-if="institutions.length > 0" class="institution-list" ref="list">
        <div
            v-for="(institution, index) in institutions"
            :key="index"
            class="institution-item"
            @click="handleInstitutionClick(institution)"
        >
          <img
              :src="institution.imageUrl"
              alt="机构图标"
              class="icon"
          />
          <div class="content">
            <p class="name">{{ institution.institutionName }}</p>
            <p class="distance">{{ institution.latitude.toFixed(2) }}km</p>
          </div>
        </div>
      </div>
    </div>
<!--    我的签约团队-->
    <div v-if="flag2" class="my-contracted-team" @click="handleDocotrTeamClick()">
      <h2>我的签约团队</h2>
      <div class="team-card">
        <img
            :src="doctorTeam.imageUrl"
            alt="团队图标"
            class="team-icon"

        />
        <h3>{{ doctorTeam.teamName }}</h3>
        <p>签约医生：{{ doctor.doctorName }}</p>
        <button class="apply-button" @click.stop="handleApplyButtonClick()">申请服务</button>
      </div>
    </div>
    <hr class="custom-hr" />
<!--    服务提醒-->
    <div v-if="flag2" class="service-reminder">
      <h2>服务提醒</h2>
      <div
          v-for="(reminder, index) in reminders"
          :key="index"
          class="reminder-item"
          @click="handleReminderClick(index)"
      >
        <div class="icon-wrapper">
          <img
              src="http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E6%97%A0%E6%B6%88%E6%81%AF.png?e=1739259511&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:DBsFqz0EVH1fVGxak_fNUBe7QYs="
              alt="提醒图标"
              class="icon"
          />
        </div>
        <div class="content-wrapper">
          <div class="title">{{ reminder.title }}</div>
          <div class="description">{{ reminder.description }}</div>
          <div class="right-icon">
            <span class="dot"></span>
            <img
                src="http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%8F%B3%E7%AE%AD%E5%A4%B4.png?e=1739260317&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:rE1nmmG5I2gMYq-bQjxJ3OKzgFM="
                alt="箭头图标"
                class="arrow-icon"
            />
          </div>
        </div>
      </div>
      <div v-if="reminders.length > 0" class="no-more">没有更多了</div>
    </div>
<!--    附近团队-->
    <div v-if="flag1" class="nearby-institutions1">
    <div class="header">
      <h2>附近团队</h2>
      <a href="#" class="more1" @click.prevent="showMore1">查看更多 ></a>
    </div>
    <div class="team-list">
      <div
          class="team-item"
          v-for="(team, index) in teams"
          :key="index"
          @click="handleTeamClick(team)"
      >
        <img :src="team.imageUrl" alt="Team Image" class="team-image" />
        <div class="team-info">
          <h3>{{ team.teamName }}</h3>
          <p>{{ team.location }}</p>
          <p>距您{{ team.rating }}km</p>
        </div>
      </div>
    </div>
    </div>
    <!-- 签约提示框 -->

      <elDialog
          title="提示"
          :visible.sync="showPrompt"
          width="80%"
          style="margin-top: 200px"
          customClass="customDialog"

      >
        <p>签约后可以使用此功能，立即签约吗？</p>
        <div slot="footer" class="dialogFooter">
          <elButton @click="delaySigning">稍后</elButton>
          <elButton type="primary" @click="goToSign">去签约</elButton>
        </div>
      </elDialog>
    <!-- 底部导航栏 -->
    <div class="bottom-nav">
      <div class="nav-item">
        <van-tabbar v-model="activeName">
          <van-tabbar-item  icon="wap-home-o" @click="tiaozhuan(activeName)">首页</van-tabbar-item>
          <van-tabbar-item  icon="comment" @click="tiaozhuan(activeName)">消息</van-tabbar-item>
          <van-tabbar-item  icon="user-o" @click="tiaozhuan(activeName)">我的</van-tabbar-item>
        </van-tabbar>
      </div>
    </div>
  </div>
  </div>
</template>

<script>
import {remind} from "@/views/index/remind/remind";

export default {
  data() {
    return {
      showHeader: false,
      showPrompt: false, // 控制提示框的显示
      qianyuestatus: false,
      // 服务提醒
      reminders: [
        {
          title: "服务申请进度提醒",
        },
        // {
        //   title: "服务申请进度提醒",
        //   description: "医生已经通过了您的签约申请，查看..."
        // }
      ],
      // 我的签约团队
      teamInfo: {},
      searchQuery: '',
      activeName: 0,
      flag1: true,
      flag2: false,
      // 轮播图数据
      carouselItems: [
        {
          image: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E8%BD%AE%E6%92%AD%E5%9B%BE%E8%83%8C%E6%99%AF.png?e=1739237404&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:P8Ox_tt3gbqwi8aO17jWUhvc2kQ=', // 替换为实际图片地址
          title: '家庭医生线上签约已开通',
          illustration: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%8C%BB%E7%94%9F%20%281%29.png?e=1739242277&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:06diuUJMbOOaWdTdVffmVnPRa1c=',
          subtitle: '提交签约申请 通过即可享受服务',
          buttonText: '立即体验',
          action: () => {
            console.log('轮播图按钮点击');
          }
        },
        {
          image: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E8%BD%AE%E6%92%AD%E5%9B%BE%E8%83%8C%E6%99%AF.png?e=1739237404&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:P8Ox_tt3gbqwi8aO17jWUhvc2kQ=', // 替换为实际图片地址
          title: '家庭医生线上签约已开通',
          illustration: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%8C%BB%E7%94%9F%20%281%29.png?e=1739242277&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:06diuUJMbOOaWdTdVffmVnPRa1c=',
          subtitle: '提交签约申请 通过即可享受服务',
          buttonText: '立即体验',
          action: () => {
            console.log('轮播图按钮点击');
          }
        },
        {
          image: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E8%BD%AE%E6%92%AD%E5%9B%BE%E8%83%8C%E6%99%AF.png?e=1739237404&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:P8Ox_tt3gbqwi8aO17jWUhvc2kQ=', // 替换为实际图片地址
          title: '家庭医生线上签约已开通',
          illustration: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%8C%BB%E7%94%9F%20%281%29.png?e=1739242277&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:06diuUJMbOOaWdTdVffmVnPRa1c=',
          subtitle: '提交签约申请 通过即可享受服务',
          buttonText: '立即体验',
          action: () => {
            console.log('轮播图按钮点击');
          }
        },
        {
          image: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E8%BD%AE%E6%92%AD%E5%9B%BE%E8%83%8C%E6%99%AF.png?e=1739237404&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:P8Ox_tt3gbqwi8aO17jWUhvc2kQ=', // 替换为实际图片地址
          title: '家庭医生线上签约已开通',
          illustration: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%8C%BB%E7%94%9F%20%281%29.png?e=1739242277&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:06diuUJMbOOaWdTdVffmVnPRa1c=',
          subtitle: '提交签约申请 通过即可享受服务',
          buttonText: '立即体验',
          action: () => {
            console.log('轮播图按钮点击');
          }
        }
        // 可添加更多轮播项
      ],
      currentCarouselIndex: 0,
      //附近机构
      institutions: [

      ],
      touchStartX: 0,
      touchEndX: 0,
      translateX: 0,
      doctor:{},
      doctorTeam:{},
      serviceApplicationList:{},
      // 附近团队
      teams: [
      ],
      // 功能按钮数据
      functionButtons: [
        {
          icon: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%81%A5%E5%BA%B7%E6%A1%A3%E6%A1%88.png?e=1739241475&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:LVT5NJ7x9fmkKetzeupucECUxjU=', // 替换为实际图标地址
          text: '健康档案',
          action: () => {
            if (this.qianyuestatus){
              this.$router.push({ name: 'indexHealthFile' });
            }else {
              this.showPrompt = true;
            }
          },
          color: '#f3756e',
        },
        {
          icon: '\n' +
              'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%81%A5%E5%BA%B7%E7%9B%91%E6%B5%8B-01.png?e=1739241622&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:UWcoHPzziVuh3z_d5D2HMP078Oc=',
          text: '健康监测',
          action: () => {

            if (this.qianyuestatus){
              this.$router.push({ name: 'healthIndex' });
            }else {
              this.showPrompt = true;
            }
          },
          color: '#f9dc7b',
        },
        {
          icon: 'http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%9C%A8%E7%BA%BF%E7%AD%BE%E7%BA%A6.png?e=1739241517&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:V_CHEFVQfdH7vQbnk9xNumIFuFQ=',
          text: '在线签约',
          action: () => {
            if (this.qianyuestatus){
              console.log('在线签约按钮点击');
              this.$router.push({ name: 'signing' });
            }else {
              this.showPrompt = true;
            }
          },
          color: '#43d094'
        }
      ],
      // 功能列表数据
      functionList: [
        {
          icon: "http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E4%B9%A6%E6%9C%AC%20%284%29.png?e=1739241080&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:uMRTMUnjec7MjD0cTG1MPUSCPAA=",
          text: '健康头条',
          action: () => {
            this.$router.push({name: 'health'});
          }
        },
        {
          icon: "http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%B1%85%E5%AE%B6%E6%8A%A4%E7%90%86.png?e=1739241191&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:VOPt75CKLhc4UpBXirMDN3m1B-s=",
          text: '慢病护理',
          action: () => {
            this.$router.push({name: 'lentivirus'});
          }
        },
        {
          icon: "http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E5%A4%84%E6%96%B9%E7%94%A8%E8%8D%AF%E6%9F%A5%E8%AF%A2.png?e=1739241179&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:BDzJgRRD88i9VVH2PgpbF3FUEJc=",
          text: '用药查询',
          action: () => {
            this.$router.push({ name: 'pharmacy' });
          }
        },
        {
          icon: "http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E7%94%A8%E8%8D%AF%E6%8F%90%E9%86%92.png?e=1739241222&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:SLbL2LqrQ8XW1WAkm23-eg4OwaE=",
          text: '用药提醒',
          action: () => {
            this.$router.push({ name: 'remind' });
          }
        }
      ],
      // 底部导航栏数据
      bottomNavItems: [
        {
          icon: 'home-icon.png',
          text: '首页',
          action: () => {
            console.log('首页按钮点击');
          }
        },
        {
          icon:'message-icon.png',
          text: '消息',
          action: () => {
            console.log('消息按钮点击');
          }
        },
        {
          icon: 'profile-icon.png',
          text: '我的',
          action: () => {
            console.log('我的按钮点击');
          }
        }
      ]
    };
  },

  mounted() {
      this.startAutoPlay();
    window.addEventListener('scroll', this.handleScroll);
    // 可添加轮播图自动播放逻辑
    setTimeout(() => {
      this.teamInfo = {
        teamName: '李明明团队',
        teamLeader: '李明明',
        doctor: '王倩',
        imageUrl: "http://srhtngjmu.hn-bkt.clouddn.com/wanmai/%E8%8D%AF%E5%93%81-3.png?e=1739258312&token=rWxRhgEIi6r6WpeIwlvhTEPMnsDCB8KqZ34tVS7A:jaT2k2K2c4LhWFIJ8EkBvKMfAFM="
      };
    }, 1000);
  },
  beforeDestroy() {
    this.stopAutoPlay();
    window.removeEventListener('scroll', this.handleScroll);
  },
  methods: {
    // 导航到签约页面
    goToSign() {
      console.log("导航到签约页面");
      this.$router.push({ name: 'indexHealthRecord' });
      // 实际应用中，这里可以替换为路由跳转，例如 this.$router.push({ path: '/sign' })
      this.showPrompt = false; // 关闭提示框
    },
    // 用户选择稍后签约
    delaySigning() {
      console.log("用户选择稍后签约");
      this.showPrompt = false; // 关闭提示框
    },
    handleScroll() {
      const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
      this.showHeader = scrollTop > 0;
    },
    // 服务提醒
    handleReminderClick(index) {
      // 这里可以编写点击后跳转页面的逻辑，例如使用 vue - router 进行跳转
      console.log("点击了提醒项", index);
      this.$router.push({ name: 'followService' })
      // 示例：假设使用 vue - router
      // this.$router.push({ name: 'SomeRouteName', params: { id: index } });
    },
    handleInput() {
      // 这里可以添加输入时的逻辑，比如实时搜索
      this.$router.push({ name: 'input' })
    },
    handleSearch() {
      // 这里可以添加点击搜索图标的逻辑，比如发起搜索请求
      console.log('执行搜索，关键词：', this.searchQuery);
    },
    startAutoPlay() {
      this.timer = setInterval(() => {
        this.nextSlide();
      }, 3000); // 每 3 秒切换一次
    },
    nextSlide() {
      this.currentCarouselIndex = (this.currentCarouselIndex + 1) % this.carouselItems.length;
    },
    prevSlide() {
      this.currentCarouselIndex = (this.currentCarouselIndex - 1 + this.carouselItems.length) % this.carouselItems.length;
    },
    stopAutoPlay() {
      clearInterval(this.timer);
    },
    // 轮播图切换方法
    goToCarouselSlide(index) {
      this.currentCarouselIndex = index;
    },
    // 轮播图按钮点击处理方法
    handleCarouselButtonClick(action) {
      this.flag1 = !this.flag1;
      this.flag2 = !this.flag2;
      action();
    },
    // 功能按钮点击处理方法
    handleFunctionButtonClick(action) {
      action();
    },
    // 功能列表项点击处理方法
    handleFunctionListItemClick(action) {
      action();
    },
    //附近机构
    handleInstitutionClick(institution) {
      // 点击机构后的逻辑，例如跳转页面等
      console.log("点击了机构:", institution);
      this.$router.push({path: 'institution', query: { institutionId: institution.id }});
    },
    openLocation(){
      console.log('打开定位');
      this.$router.push({ path: '/indexRegion' });
    },
    showMore() {
      // 查看更多的逻辑，例如加载更多数据或跳转页面
      console.log("点击了查看更多");
      this.$router.push({ name: 'nearbyMechanism' });
    },
    showMore1() {
      // 查看更多的逻辑，例如加载更多数据或跳转页面
      console.log("点击了查看更多");
      this.$router.push({ name: 'nearbyMechanismtd' });
    },
    // 附近团队点击跳转
    handleTeamClick(team) {
      // 这里可以编写点击团队后跳转页面或其他逻辑
      console.log("点击了团队:", team);
      this.$router.push({ name: 'doctorTeam1', query: { teamId: team.id } });
    },
    handleDocotrTeamClick(){
      this.$router.push({ name: 'myDoctor' });
    },
    findRemindAll(){
      this.axios.get('http://localhost:10086/api/doctor/drug_reminder/findAll').then(res => {
        if (res.data.code === 200){
          let reminders = res.data.data;
          localStorage.setItem('reminders', JSON.stringify(reminders));
          setTimeout(() => {
            remind.$emit('updateReminders', reminders);
          },666)
        }
      });
    },
    // 底部导航栏点击处理方法
    tiaozhuan(activeName) {
      switch (activeName) {
        case 1:
          this.$router.push({ name: 'message' });
          break;
        case 2:
          this.$router.push({ name: 'my' });
          break;
        default:
          break;
      }
    },
    institution(regionName){
      this.axios.get('http://localhost:10086/api/user/medical_institution/findByRegionName').then(res => {
        if (res.data.code === 200){
          this.institutions = res.data.data;
          console.log(this.institutions);
        }
      });

    },
    team(){
      this.axios.get('http://localhost:10086/api/doctor/doctor_team/findDoctorTeamByRegionName').then(res => {
        if (res.data.code === 200){
          this.teams = res.data.data;
          console.log(this.teams);
        }
      });
    },
    qianyue(){
      this.axios.get('http://localhost:10086/api/agency/contract_application/getContractApplicationDetail').then(res => {
        if (res.data.code === 200){
          this.qianyuestatus = res.data.data;
          console.log("签约状态"+this.qianyuestatus)
          if (this.qianyuestatus){
            this.flag1 = false;
            this.flag2 = true;
          }
        }

      });
    },
    handleApplyButtonClick(){
      this.$router.push({ name: 'apply' })
    },
    findAll(){
      this.axios.get('http://localhost:10086/api/agency/contract_application/findApplicationDoctor').then(res => {
        if (res.data.code === 200){
          this.doctor = res.data.data.doctor;
          this.doctorTeam = res.data.data.doctorTeam;
          console.log(this.doctor.id)
          localStorage.setItem('doctorId', JSON.stringify(this.doctor.id))
        }
      });
    },
    findServiceApplicationListByUserId(){
      this.axios.get('http://localhost:10086/api/service/service_application/findServiceApplicationListByUserId').then(res => {
        if (res.data.code === 200){
          this.serviceApplicationList = res.data.data;
          this.reminders[0].description = this.serviceApplicationList.servicePackageName+this.serviceApplicationList.serviceItem+this.serviceApplicationList.status
          console.log(this.serviceApplicationList)
        }
      });
    }

  },
  watch: {
    flag1 (newValue) {
      if (newValue===false) {
        this.findAll()
      }
    }
  },
  created() {
    const token = JSON.parse(localStorage.getItem("token"));
    if (!token) {
      this.$message.error('请先登录');
      setTimeout(() => {
        this.$router.push({name: 'login'});
      }, 666);
    }
    // 设置全局默认请求头
    this.axios.defaults.headers.common['token'] = token;
    this.findRemindAll()
    let regionName =this.$route.query.regionName
    console.log(regionName)
    // if (regionName===undefined){
    //   regionName = "北京市";
    // }
    this.qianyue();
    this.findServiceApplicationListByUserId()
    this.institution();
    this.team();


  },
};
</script>

<style scoped>
@import "../index/Index.css";
</style>